﻿/*----------------------------------------------------------------
//   Copyright (C) 2012 YMSOFT All rights reserved 
//
//   CLR版本:   2.0.50727.3634
//   Namespace: ART.Common
//   FileName : Configs
//   Description: 
// 
//   Created by YAOMING at 2012-10-11 16:50:39
//   http://www.loverer.com QQ:78867011
//
//   Modified: 
//   Modify description: 
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace ART.Common
{
    public class Configs
    {
        /// <summary>
        /// 获取指定的WebConfig配置字符串
        /// </summary>
        /// <param name="appSettingKey">配置名称</param>
        public static string GetWebConfigSetting(string appSettingKey)
        {
            string keyValue = "";
            if (System.Configuration.ConfigurationManager.AppSettings[appSettingKey] != null)
                keyValue = System.Configuration.ConfigurationManager.AppSettings[appSettingKey].ToString();
            return keyValue;
        }


        public static string GetXmlNode(string strXmlPath, string strNode)
        {
            XmlDocument document = new XmlDocument();
            document.Load(strXmlPath);
            if (document.SelectSingleNode(strNode)!=null)
            {
                return document.SelectSingleNode(strNode).InnerText;
            } 
            else
            {
                return "";
            }
        }

        public static string SetXmlNode(string path, string nodeName, string nodeValue)
        {
            XmlDocument document = new XmlDocument();
            document.Load(path);

            document.SelectSingleNode(nodeName).InnerText = nodeValue;
            document.Save(path);
            return nodeValue;
        }
       
    }
}
